atom.declare( 'Animator.Helpers.Box', 
{
  initialize : function(obj)
  {
    Animator.Helpers.System.argumentAssertion(arguments, "object");
    this.fields = {};
    this.hash = 0;
    Animator.Helpers.Box._expand.call(this, obj, "");
  },
  
  isEqual : function(box)
  {
    if(box instanceof Animator.Helpers.Box)
    {
      if(this.hash !== box.hash)
        return false;
      for(var p in this.fields)
        if(this.fields[p] !== box.fields[p])
          return false;
      return true;
    }
    else
      return Animator.Helpers.Box._isEqual.call(this, box, "");
  }
}).own(
{
  _expand : function _expand_fnc(obj, n)
  {
    for(var p in obj)
    {
      var v = obj[p];
      var pn = p + n;
      var to = typeof(v);
      if(to === "function")
        continue;
      else if(to === "object")
        _expand_fnc.call(this, v, pn);
      else
      {
        this.fields[pn] = v;
        this.hash += pn.length;
      }
    }
  },
  
  _isEqual : function _is_equal_fnc(obj, n)
  {
    for(var p in obj)
    {
      var v = obj[p];
      var pn = p + n;
      var to = typeof(v);
      if(to === "function")
        continue;
      else if(to === "object")
      {
        if(!_is_equal_fnc.call(this, v, pn))
          return false;
      }
      else if(this.fields[pn] !== v)
        return false;
    }  
    return true;
  }
});